import 'package:flutter/material.dart';

class LayOutBuilderPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('模板'),
      ),
      // 公共默认的 页面样式

      // 继承上级  DefaultTextStyle.merge
      body: DefaultTextStyle(
        style: const TextStyle(fontSize: 14, color: Colors.yellow),
        // 公共默认的 icon样式
        child: IconTheme(
          data: IconThemeData(color: Colors.red),
          // 可以传参数 minimum 如果有间距 用间距，没有安全间距 用 minimum
          child: SafeArea(
            bottom: false,
            left: false,
            right: false,
            minimum: EdgeInsets.only(top: 8),
            child: Column(
              children: [
                Icon(Icons.add),
                Text('123'),
                Center(
                  child: Container(
                    width: 200,
                    height: 200,
                    color: Colors.red[200],
                    alignment: Alignment.center,
                    child: LayoutBuilder(
                      builder:
                          (BuildContext context, BoxConstraints constraints) {
                        print('${constraints.maxWidth}');
                        return FlutterLogo(
                          size: constraints.maxWidth / 2,
                        );
                      },
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
